<template>
	<view class="content">
		<view class="navbar">
			<view v-for="(item, index) in navList" :key="index" class="nav-item"
				:class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
		</view>
		<swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
			<swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
				<scroll-view class="list-scroll-content" scroll-y>
					<!-- 空白页 -->
					<!-- <u-empty text="暂无订单" mode="list"></u-empty> -->
					<!-- 订单列表 -->
					<view class="seller-view" v-for="(order, oderIndex) in tabItem.orderList" :key="oderIndex">
						<!-- 店铺名称 -->
						<view class="seller-info u-flex u-row-between">
							<view class="seller-name wes" @click="navigateToStore()">
								<view class="name wes">订单编号：xxxxxxxx</view>
							</view>
							<view class="order-sn"> <text>已完成</text> | <u-icon class="icon" name="close-circle"
									size="36" color="#e2777a"></u-icon>
							</view>
						</view>
						<view>
							<view>
								<view class="goods-item-view" @click="navigateToOrderDetail()">
									<view class="goods-img" :key="goodsIndex">
										<u-image border-radius="6" width="100%" height="100%"
											src="https://lilishop-oss.oss-cn-beijing.aliyuncs.com/0f423fb60f084b2caade164fae25a9a0.png">
										</u-image>
									</view>
									<view class="goods-info">
										<view class="goods-title u-line-2">
											商品名字
										</view>
										<view class="goods-price">
											￥231
										</view>
									</view>
									<view class="goods-num">
										<view>x3</view>
									</view>
								</view>
							</view>
							<view class="btn-view u-flex u-row-between">
								<view class="description">
									<div>已付金额:</div>
									<div class="price">￥123</div>
								</view>
								<view class="goods-btn flex flex-a-c">
									<view ripple class="pay-btn" shape="circle" size="mini" @click="waitPay()">立即付款
									</view>
								</view>
							</view>
						</view>
					</view>
					<uni-load-more :status="tabItem.loadStatus"></uni-load-more>
				</scroll-view>
			</swiper-item>
		</swiper>
		<u-toast ref="uToast" />
		
	</view>
</template>

<script>
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue";

	export default {
		components: {
			uniLoadMore,
		},
		data() {
			return {
				lightColor: this.$lightColor,
				tabCurrentIndex: 0, //导航栏索引
				navList: [
					//导航栏list
					{
						state: 0,
						text: "全部",
						loadStatus: "more",
						orderList: [{}, {}],
						pageNumber: 1,
					},
					{
						state: 1,
						text: "已取消",
						loadStatus: "more",
						orderList: [{}, {}],
						pageNumber: 1,
					},
					{
						state: 2,
						text: "待支付",
						loadStatus: "more",
						orderList: [{}, {}],
						pageNumber: 1,
					},
					{
						state: 3,
						text: "已支付",
						loadStatus: "more",
						orderList: [{}, {}],
						pageNumber: 1,
					},
					{
						state: 4,
						text: "退款中",
						loadStatus: "more",
						orderList: [{}, {}],
						pageNumber: 1,
					},
					{
						state: 5,
						text: "已退款",
						loadStatus: "more",
						orderList: [{}, {}],
						pageNumber: 1,
					},
					{
						state: 6,
						text: "已完成",
						loadStatus: "more",
						orderList: [{}, {}],
						pageNumber: 1,
					},
				],
			};
		},


		onLoad(options) {
			console.log(options)
		},

		watch: {

		},
		methods: {
			//顶部tab点击
			tabClick(index) {
				this.tabCurrentIndex = index;
			},

			//swiper 切换监听
			changeTab(e) {
				this.tabCurrentIndex = e.target.current;
			},

			// 店铺详情
			navigateToStore(val) {
				uni.navigateTo({
					url: "/pages/product/shopPage",
				});
			},

			/**
			 * 跳转到订单详情
			 */
			navigateToOrderDetail() {
				uni.navigateTo({
					url: "./orderDetail",
				});
			},
			
			/**
			 * 等待支付
			 */
			waitPay() {
				uni.navigateTo({
					url: '/pages/order/fillorder',
				});
			},

		},
	};
</script>

<style lang="scss" scoped>
	page,
	.content {
		background: $page-color-base;
		height: 100%;
	}

	.swiper-box {
		height: calc(100vh - 40px);
		// #ifdef H5
		height: calc(100vh - 40px - 44px);
		// #endif
	}

	.list-scroll-content {
		height: 100%;
	}

	.navbar {
		display: flex;
		height: 40px;
		padding: 0 5px;
		background: #fff;
		box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
		position: relative;
		z-index: 10;

		.nav-item {
			flex: 1;
			display: flex;
			justify-content: center;
			align-items: center;
			height: 100%;
			font-size: 26rpx;
			color: $font-color-light;
			position: relative;

			&.current {
				color: $main-color;

				&:after {
					content: "";
					position: absolute;
					left: 50%;
					bottom: 0;
					transform: translateX(-50%);
					width: 44px;
					height: 0;
					border-bottom: 2px solid $main-color;
				}
			}
		}
	}

	.uni-swiper-item {
		height: auto;
	}

	.seller-view {
		border-radius: 20rpx;
		background-color: #fff;
		margin: 20rpx 0rpx;

		.seller-info {
			height: 70rpx;
			padding: 0 20rpx;

			.seller-name {
				flex: 10;
				font-size: 28rpx;
				font-weight: 600;
				display: flex;
				flex-direction: row;

				.name {
					margin-left: 15rpx;
					margin-top: -2rpx;
				}
			}

			.order-sn {
				width: 180rpx;
				text-align: center;
				color: $aider-light-color;
				font-size: 26rpx;

				text {
					margin-right: 20rpx;
				}

				.icon {
					margin-left: 20rpx;
				}
			}
		}

		.goods-item-view {
			display: flex;
			flex-wrap: wrap;
			flex-direction: row;
			padding: 10rpx 20rpx;

			.goods-img {
				width: 131rpx;
				height: 131rpx;
				margin-right: 10rpx;
				margin-bottom: 10rpx;
			}

			.goods-info {
				padding-left: 30rpx;
				flex: 1;

				.goods-title {
					margin-bottom: 10rpx;
					color: #333333;
				}

				.goods-specs {
					font-size: 24rpx;
					margin-bottom: 10rpx;
					color: #cccccc;
				}

				.goods-price {
					font-size: 28rpx;
					margin-bottom: 10rpx;
					color: $aider-light-color;
				}
			}

			.goods-num {
				width: 60rpx;
				color: $main-color;
			}
		}

		.btn-view {
			padding: 25rpx 30rpx;
			font-size: 26rpx;

			.description {
				display: flex;
				color: #909399;
				size: 24rpx;
				flex: 1;

				.price {
					color: $main-color;

				}
			}
		}
	}

	.cancel-popup {
		.header {
			display: flex;
			flex-direction: row;
			justify-content: center;
			margin: 15rpx 0rpx;
		}

		.body {
			padding: 30rpx;

			.title {
				font-weight: 600;
			}

			.value {
				display: flex;
				flex-direction: column;
				margin: 20rpx 0;

				.radio-view {
					margin: 20rpx 0rpx;
				}
			}
		}

		.footer {
			text-align: center;
		}
	}

	.goods-btn {
		display: flex;
	}

	.cancel-btn,
	.pay-btn,
	.rebuy-btn {
		text-align: center;
		margin-left: 15rpx;
		font-size: 24rpx;
		padding: 14rpx 20rpx;
		border-radius: 100px;

	}

	.cancel-btn {
		color: #333639 !important;
		background: rgba(46, 51, 56, .05) !important;
	}

	.pay-btn {

		background-color: $light-color !important;

		color: #ffffff !important;
	}

	.rebuy-btn {
		color: $light-color !important;
		border-color: $light-color !important;
		background-color: #ffffff !important;
	}
</style>
